[SYCL] Use compiler-rt builtin library in SYCL for spirv target - #23111
[SYCL] Use compiler-rt builtin library in SYCL for spirv target#23111jinge90 wants to merge 8 commits into
Conversation
Signed-off-by: jinge90 <ge.jin@intel.com>
Signed-off-by: jinge90 <ge.jin@intel.com>
Signed-off-by: jinge90 <ge.jin@intel.com>
There was a problem hiding this comment.
🟡 Changes recommended
macOS, custom JIT configurations, and clean parallel builds can fail to produce or locate the required builtins bitcode.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Integrates SPIR-V compiler-rt builtins into SYCL device linking and removes duplicated complex arithmetic implementations.
Changes:
- Builds, packages, and discovers SPIR-V compiler-rt bitcode.
- Links builtins through the SYCL driver and JIT compiler.
- Replaces libdevice complex helpers and updates driver tests.
File summaries
| File | Description |
|---|---|
sycl/CMakeLists.txt |
Adds SPIR-V builtins to toolchain deployment. |
sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp |
Loads compiler-rt during JIT linking. |
sycl-jit/jit-compiler/CMakeLists.txt |
Embeds SPIR-V builtins in JIT resources. |
libdevice/fallback-complex.hpp |
Uses compiler-generated float complex helpers. |
libdevice/fallback-complex-fp64.hpp |
Uses compiler-generated double complex helpers. |
libdevice/complex_wrapper.hpp |
Removes duplicated builtin wrappers. |
libdevice/cmake/modules/SYCLLibdevice.cmake |
Enables strict complex arithmetic lowering. |
compiler-rt/lib/builtins/CMakeLists.txt |
Adds the SPIR-V address-space flag. |
compiler-rt/cmake/builtin-config-ix.cmake |
Detects support for that flag. |
clang/test/Driver/sycl-no-rdc-win.cpp |
Updates phase indices. |
clang/test/Driver/sycl-no-rdc-old-model.cpp |
Updates phase indices. |
clang/test/Driver/sycl-no-rdc-fat-archive-win.cpp |
Updates phase indices. |
clang/test/Driver/sycl-no-rdc-fat-archive-old-model.cpp |
Updates phase indices. |
clang/test/Driver/Inputs/SYCL/lib/clang/resource_dir/lib/spirv64-unknown-unknown/libclang_rt.builtins.bc |
Adds a driver-test fixture. |
clang/lib/Driver/ToolChains/SYCL.cpp |
Selects and locates SPIR-V builtins. |
clang/lib/Driver/Driver.cpp |
Adds the builtins directory to legacy linking. |
buildbot/configure.py |
Configures the SPIR-V compiler-rt runtime. |
Review details
- Files reviewed: 16/17 changed files
- Comments generated: 4
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| "libsycl-imf", | ||
| "libclang_rt.builtins"}; |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: jinge90 <ge.jin@intel.com>
Signed-off-by: jinge90 <ge.jin@intel.com>
There was a problem hiding this comment.
🟡 Changes recommended
Builtins are unavailable in optional-runtime configurations and incompatible with currently selected 32-bit SPIR targets.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (2)
Previously missed (1) — in code that hasn't changed since the last review.
libdevice/fallback-complex.hpp:69
- This replacement removes the implementation of the documented
cl_intel_devicelib_complexentry points__devicelib___mulsc3and__devicelib___divsc3, butsycl/doc/design/DeviceLibExtensions.rst:193-194still advertises them. Update the extension contract (and the corresponding fp64 declarations at lines 233-234) so consumers are not promised symbols that libdevice no longer provides.
clang/lib/Driver/ToolChains/SYCL.cpp:682
- This makes
libclang_rt.builtins.bcmandatory for every SPIR/SPIR-V compilation, butsycl/CMakeLists.txtstill builds and deploys it only when a SPIR-V compiler-rt target happens to be configured. A toolchain configured without that optional runtime now reportserr_drv_no_sycl_device_libfor ordinary SYCL compilation, while the previous fallback definitions have been removed. Make compiler-rt a configure-time requirement or retain/select a valid fallback when the library is unavailable.
"libsycl-imf",
"libclang_rt.builtins"};
- Files reviewed: 17/18 changed files
- Comments generated: 2
- Review effort level: Balanced
| if (!TC.getTriple().isSPIROrSPIRV()) | ||
| return; | ||
| SmallString<128> SPIRVCompilerRTPath(TC.getCompilerRTPath()); | ||
| llvm::sys::path::append(SPIRVCompilerRTPath, "spirv64-unknown-unknown"); |
There was a problem hiding this comment.
Currently, all device libraries only provide spir64 versions, we don't support 32-bit.
| "libsycl-imf", | ||
| "libclang_rt.builtins"}; |
There was a problem hiding this comment.
We will always build compiler-rt for spirv64 targets in intel/llvm sycl compiler.
Most changes to compiler-rt to make spirv build pass have been submitted to commnuity. This PR aims to build and link compiler-rt builtin library for spirv target and use it in SYCL compiler. We will remove __mulsc3/__muldc3/__divsc3/__divdc3/ in libdevice and use the same functions from compiler-rt builtin library.